import * as Sequelize from 'sequelize';
import { DataTypes, Model, Optional } from 'sequelize';

export interface adminAttributes {
  id: number;
  account?: string;
  name: string;
  password: string;
  admin: number;
  status: number;
  createdAt: Date;
  updatedAt: Date;
}

export type adminPk = "id";
export type adminId = admin[adminPk];
export type adminOptionalAttributes = "id" | "account" | "password" | "admin" | "status" | "createdAt" | "updatedAt";
export type adminCreationAttributes = Optional<adminAttributes, adminOptionalAttributes>;

export class admin extends Model<adminAttributes, adminCreationAttributes> implements adminAttributes {
  id!: number;
  account?: string;
  name!: string;
  password!: string;
  admin!: number;
  status!: number;
  createdAt!: Date;
  updatedAt!: Date;


  static initModel(sequelize: Sequelize.Sequelize): typeof admin {
    return admin.init({
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      primaryKey: true,
      comment: "管理员主键ID"
    },
    account: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: "账号"
    },
    name: {
      type: DataTypes.STRING(50),
      allowNull: false,
      comment: "昵称"
    },
    password: {
      type: DataTypes.STRING(255),
      allowNull: false,
      defaultValue: "3282facaf98ef20c816f3a91edcccc33",
      comment: "登录密码"
    },
    admin: {
      type: DataTypes.TINYINT,
      allowNull: false,
      defaultValue: 0,
      comment: "1为管理员 9超级管理员"
    },
    status: {
      type: DataTypes.TINYINT,
      allowNull: false,
      defaultValue: 1,
      comment: "默认 1为  0为禁用"
    }
  }, {
    sequelize,
    tableName: 'admin',
    timestamps: true,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
  }
}
